/*CCP 1.3
Given two strings, write a method to decide if one is a permutation of the other.
*/
#include <iostream>
#include <string>
using namespace std;

//space complexity:O(n)
//time complexity:O(1) O(256)
bool isPalindrome(string& s1,string& s2)
{
	if(s1.length() != s2.length())
		return false;
	int count[256]={0};
	for(int i=0;i < s1 .length();i++)
	{
		count[s1[i]]++;
		count[s2[i]]--;
	}
	for(int i=0;i<256;i++)
	{
		if(count[i] != 0)
			return false;
	}
	return true;		
}

int main()
{
	string s1 ="abacccdefg";
	string s2 ="bcadcefgac";
	cout<<isPalindrome(s1,s2)<<endl;
	return 0;
}